/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Servlet.errors;

import Logger.MyLogger;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author marcello
 */
public class internalError extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        MyLogger.getLogger().debug("Pagina errore 500 -> internalError");
        PrintWriter out = response.getWriter();
        String path = request.getContextPath();
        path += "/";
        try {
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<link href='http://fonts.googleapis.com/css?family=Quicksand:300,400' rel='stylesheet' type='text/css' /> "
                    + "<link href=\"" + path + "css/smoothness/jquery-ui-1.8.16.custom.css\" type=\"text/css\" rel=\"stylesheet\"  />"
                    + "<link href=\"" + path + "css/stile.css\" type=\"text/css\" rel=\"stylesheet\" />"
                    + "<script src=\"" + path + "js/jquery-1.6.2.min.js\" ></script>"
                    + "<script src=\"" + path + "js/jquery-ui-1.8.16.custom.min.js\" ></script>"
                    + "<script src=\"" + path + "js/sha1.js\" ></script>"
                    + "<style>"
                    + "*{font-family: 'Quicksand', sans-serif; }"
                    + "</style>"
                    + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"
                    + "<title>Portale Vaccinazioni</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<div id='cont'> "
                    +"<h3>Siamo spiacenti ma si è verificato un errore imprevisto. Le chiediamo gentilmente di "
                    + "riprovare più tardi.<br/>"
                    + "Clicchi <a href=\""+path+"ogout\">qui</a></h3> per tornare alla pagina di login "
                    + "<a href=\"logout\">link</a></h3>"
                    + "</div>");
            out.println("</body>");
            out.println("</html>");

        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
